package com.example.gausspaper.domain;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import java.io.Serializable;

@Data
@Entity(name = "db_PaperHasTag")
@IdClass(PaperHasTagId.class)
public class PaperHasTag {
    @Id
    @Column(length = 10)
    private String paperId;
    @Id
    @Column(length = 20)
    private String tagName;
}

@Getter
@Setter
class PaperHasTagId implements Serializable {
    private String paperId;
    private String tagName;

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof PaperHasTagId){
            PaperHasTagId pk=(PaperHasTagId)obj;
            if(this.paperId.equals(pk.paperId)&&this.tagName.equals(pk.tagName)){
                return true;
            }
        }
        return false;
    }

    @Override
    public int hashCode() {
        return super.hashCode();
    }
}
